//
//  SPTimeValue.m
//  Sampux
//
//  Created by rzm on 16/8/18.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "SPTimeValue.h"

@implementation SPTimeValue

+ (NSString *)setTimeValue:(NSString *)point
{
    
    NSInteger hour = [point integerValue]/60;
    NSInteger min = [point integerValue]%60;
    NSString *hourStr = nil;
    NSString *minStr = nil;
    
    if (hour<10) {
        hourStr = [NSString stringWithFormat:@"0%ld",(long)hour];
    }else
    {
        hourStr = [NSString stringWithFormat:@"%ld",(long)hour];
    }
    if (min<10) {
        minStr = [NSString stringWithFormat:@"0%ld",(long)min];
    }else
    {
        minStr = [NSString stringWithFormat:@"%ld",(long)min];;
    }
    return [NSString stringWithFormat:@"%@:%@",hourStr,minStr];
}

+ (NSString *)separatedTimeValueWithString:(NSString *)text
{
    
    NSInteger hour = [[text componentsSeparatedByString:@":"].firstObject integerValue];
    NSInteger min = [[text componentsSeparatedByString:@":"].lastObject integerValue];
    
    NSString *point = [NSString stringWithFormat:@"%ld",hour*60 + min];
    return point;
}

@end
